public class TriangleTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		demo5();

	}

	public static void demo1() {
		Triangle triangle1 = new Triangle();
		triangle1.setSideA(3);
		triangle1.setSideB(4);
		triangle1.setSideC(5);
		triangle1.showMe();
		System.out.println("面积为：" + triangle1.getArea());
		System.out.println("周长为：" + triangle1.getPerimeter());

		Triangle triangle2 = new Triangle();
		triangle2.setSideA(8.5);
		triangle2.setSideB(10.1);
		triangle2.setSideC(15.2);
		triangle2.showMe();
		System.out.println("面积为：" + triangle2.getArea());
		System.out.println("周长为：" + triangle2.getPerimeter());
	}

	public static void demo3() {
		int[] arrA = new int[5];
		arrA[0] = 1;
		Student[] students = new Student[5];
		students[0] = new Student();
		students[0].id = 1001;
		students[1] = new Student();
		students[1].id = 1002;
		students[2] = new Student();
		students[2].id = 1003;
		students[3] = new Student();
		students[3].id = 1004;
		students[4] = new Student();
		students[4].id = 1005;
	}

	public static void demo4() {
		Student[] students = new Student[5];
		Student s1 = new Student();
		for (int i = 0; i < students.length; i++) {
			s1.id = i;
			/**
			 * 依次把s1对象（栈区）的地址(堆区)赋值到students（栈区）的students[i]（堆区）
			 */
			students[i] = s1;
		}
		for (int i = 0; i < students.length; i++) {
			System.out.print(students[i].id + "\t");
		}
		/**
		 * 依次把students[i]所指向堆区地址（s1对象的地址）赋值给student（栈区）
		 */
		for (Student student : students) {
			System.out.print(student.id + "\t");
		}
	}

	public static void demo5() {
		Student[] students = new Student[5];
		Student s1 = null;
		for (int i = 0; i < students.length; i++) {
			s1 = new Student();
			s1.id = i;
			students[i] = s1;
		}
		for (int i = 0; i < students.length; i++) {
			System.out.print(students[i].id + "\t");
		}
	}

}
